//引入express模块
const express = require('express');
//进入连接池
const pool = require('../pool.js');
//创建路由器对象
const r = express.Router();
//http://127.0.0.1:8080/v1/select/:pid
//添加路由器
r.get('/',(req,res,next)=>{
    //获取pid的值
    let obj = req.body;
    console.log(obj);
    //运行sql命令
    pool.query('select * from scp_clothes_pic where pid=?',[obj.pid],(err,result)=>{
        if(err){
            next(err);
            return;
        }
        if(result.length===0){
            res.send({code:404,msg:'查询失败'});
        }else{
            res.send({code:200,msg:'查询成功',date:result});
        }
    });
});



//导出路由器对象让app.js获取
module.exports = r;